import Setting from '@/setting'
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import VuexPersistence from 'vuex-persist'
const files = require.context('./modules', false, /\.js$/);
const modules = {};
const vuexLocal = new VuexPersistence({
  storage: window.localStorage,
  key: 'storage',
  modules: ['user']
})

files.keys().forEach(key => {
    modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default
});

export default new Vuex.Store({
    modules,
    plugins: [vuexLocal.plugin]
})